function hideGridContainerAndShowGridSpinner() {
	$('gridContainer').hide();
	$('gridSpinner').show();
}
function hideGridSpinnerAndShowGridContainer() {
	$('gridSpinner').hide();
	$('gridContainer').show();
}
function doGrid() {
	hideGridContainerAndShowGridSpinner();
	doInitGrid();
	doFillGrid();
}



function commonGridInit(grid) {
	grid.setImagePath("scripts/dhtmlxgrid-codebase/imgs/");
	grid.enableSmartRendering(true);
	grid.enableMultiselect(true);
	grid.setSkin("dhx_skyblue");
	grid.enableBlockSelection(true);

	grid.csv.cell="\t";
	grid.attachEvent("onFilterEnd", function() {
		$('rowCount').update(grid.getRowsNum());
	});
//	grid.attachEvent("onKeyPress", onKeyPressed);
//	grid.attachEvent("onBeforeSelect", function() {
//		return false;
//	});
}

function changeGridSize(size){
	if(size=="small"){
		$('gridContainer').setStyle("height: 400px;");
		$('wholeContainer').setStyle("height: 400px;");
	}
	else if(size=="large"){
		$('gridContainer').setStyle("height: 1100px;");
		$('wholeContainer').setStyle("height: 1100px;");
	}
	else if(size=="normal"){
		$('gridContainer').setStyle("height: 700px;");
		$('wholeContainer').setStyle("height: 700px;");
	}
	else{
		$('gridContainer').setStyle("height: 700px;");
		$('wholeContainer').setStyle("height: 700px;");
	}
	doGrid();
	
}

function handleErrorReponse(transport){
	alert(transport.responseText);
}


function doExportGrid(){
	grid.enableCSVHeader(true);
	var exportWin = dhxWins.createWindow("export",500,300,500,250);
	dhxWins.window("export").setText("Copy the following text in excel :");
	exportWin.attachHTMLString("<textarea cols='70' rows='15' >"+grid.serializeToCSV(true)+'</textarea>');

	grid.csv.cell="\t";
	
	
	
	
}